/**
 * Created by heshufen on 20/7/3.
 */
import React from 'react';
import {Platform, SafeAreaView, StatusBar, StyleSheet, View} from 'react-native';

const statusBarHeight = Platform.OS === 'ios' ? 0 : StatusBar.currentHeight;

export default class Screen extends React.Component {

    navigationParams = this.props.route.params;

    constructor(props) {
        super(...arguments);

        this.state = {
            ...this.getInitState(props)
        };
    }

    getInitState(props) {
        return {}
    }

    renderStatusBar() {
        return (
            <StatusBar
                hidden={false}
                backgroundColor={'#00000000'}
                translucent={true}
                barStyle={this.getBarStyle()}
                networkActivityIndicatorVisible={true}/>
        );
    }

    renderHeader(navigation) {

    }

    renderBody(navigation) {

    }

    renderFooter() {

    }

    renderFloatViews() {
        return [];
    }

    getBarStyle() {
        return 'dark-content';
    }

    render() {
        return (
            <View style={[styles.container, this.containerStyle()]}>
                {this.renderStatusBar()}
                {this.needSafeAreaView() ? <SafeAreaView style={styles.safeAreaView}>
                    {this.renderHeader(this.props.navigation)}
                    <View style={styles.body}>
                        {this.renderBody(this.props.navigation)}
                    </View>
                    {this.renderFooter(this.props.navigation)}
                </SafeAreaView> : <View style={styles.body}>
                    {this.renderBody(this.props.navigation)}
                </View>}
                {this.renderFloatViews().map(item => item)}
            </View>
        );
    }

    containerStyle() {
        return {};
    }

    needSafeAreaView() {
        return true;
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#fff'
    },
    safeAreaView: {
        flex: 1,
        marginTop: statusBarHeight,
    },
    body: {
        flex: 1,
        zIndex: -1,
        backgroundColor:'#fff'
    },
});
